package com.maleant.mvvm.basemvvm.ui.fragment;

import android.arch.lifecycle.Lifecycle;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.maleant.mvvm.basemvvm.R;
import com.maleant.mvvm.basemvvm.databinding.ProductFragmentBinding;
import com.maleant.mvvm.basemvvm.model.Product;
import com.maleant.mvvm.basemvvm.ui.MainActivity;
import com.maleant.mvvm.basemvvm.ui.callback.ProductClickCallback;
import com.maleant.mvvm.basemvvm.ui.fragment.adapter.ProductAdapter;

/**
 * Created by ant on 17-12-20.
 */

public class ProductListFragment extends Fragment {
    public static final String TAG = ProductListFragment.class.getName();

    private ProductAdapter mProductAdapter;

    private ProductFragmentBinding mBinding;

//    private CommentAda

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        DataBindingUtil.inflate(inflater, R.layout.list_fragment, container, false);
        mProductAdapter = new ProductAdapter(mProductClickCallback);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    private final ProductClickCallback mProductClickCallback = new ProductClickCallback() {
        @Override
        public void onClick(Product product) {

            if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
//                ((MainActivity)getActivity()).show
            }
        }
    };
}
